<h1 class="right">تقرير الطلبات</h1>

<div class="clear"></div>

<div id="dashboard-container">
	<div class="customers-filter">
    	<form name="contract_search" action="" method="POST" id="searchClient">
      <table class="bookings-filter">
        	
          <tr>
		   <td width="10">من  </td>
                <td>
                  <input type="text" class="small-input" name="from" id="from-0" placeholder=""  value="<?php if(isset($binds['from']) ) {echo $binds['from'];} ?>"/>
                </td>
                <td>الى</td>
                <td><input type="text" class="small-input" name="to" id="to-0" placeholder="" value="<?php if(isset($binds['to']) ) {echo $binds['to'];} ?>" /></td>
                <td>رقم الوحدة</td>
                <td><input type="text" class="small-input" name="payment_name" value="<?php if(isset($binds['payment_name']) ) {echo $binds['payment_name'];} ?>"></td>
                <input type="hidden" id="page" name="page" value="" />
                <td></td>
                <td style="width:50px">
                  <input type="hidden" name="filteration" value="10"/> <!-- 10 for requests Reposts -->
                  <a href="#"><div class="export-button">تصدير Excel</div></a>
                  
                  <input type="hidden" id="pdf_excel" name="pdf_excel" value="100"/>
                </td>
                <td style="width:40px"><a href="#"><div class="export-PDF">تصدير PDF</div></a></td>
               <td style="width:40px"><div class="search-botton">بحث</div></td>
            </tr>
            
      </table>
      </form>
    </div>
    
    
    <div class="dashboard-row">
    
    	<table class="customers-table">
        <thead>
            <tr class="customers-table-head">
            	<td width="">رقم الوحدة</td>
              <td width="">تاريخ فتح الطلب</td>
              <td width="">وقت فتح الطلب</td>
              <td width="">تاريخ قفل الطلب</td>
              <td width="">وقت قفل الطلب</td>
              <td width="">مدة الانجاز</td>
            </tr>
            </thead>
            <?php foreach($requsts as $requst) { 
			
			
			?>
                <tr class="">
                    <td width=""><?php echo $requst['apart_name']; ?></td>
                    <td class="" width=""><?php echo $requst['date_beginning']; ?></td>
                    <td class="" width=""><?php echo $requst['time_beginning']; ?></td>
                    <td class="" width=""><?php echo $requst['date_ending']; ?></td>
                    <td width=""><?php echo $requst['time_ending']; ?></td>
					
					<?php
					if($requst['date_ending']=="0000-00-00"){
					    echo " <td class='red' > لم يتم انجازها </td> ";
					   } else {
					   $total_date= (strtotime($requst['date_ending'])-strtotime($requst['date_beginning']))/86400 ;
					   $total_time =(strtotime($requst['time_ending']) - strtotime($requst['time_beginning']))/60 ;
					  
					   if($total_time <= 60){
					   $time = round($total_time) ;
					   echo " <td > {$total_date} يوم - {$time} دقيقة </td> ";
					   }
					   else if($total_time >= 60 ){
					   $time = round($total_time/60);
					    echo " <td > {$total_date} يوم - {$time} ساعة </td> ";
					   }
					  }
					   
					?>
                  <!--  <td ><?php //echo  "ساعة"." ".$time."يوم و"." ".$total_date; ?></td> -->
                   
                </tr>
              <?php  } ?>
        </table><br />
        <hr />
        <?php
         $start = $page * 20 -19;
          $end  = $start + 19;
          if($end > $totalPages)
            $end = $totalPages
          
        ?>
        <?php if(!empty($requsts)) { ?>
        <div class="clear"></div>
        <div class="relative">
          <div id="requests-selection" class="center"></div>
          <span class="middle xsmall showing-results absolute">عرض النتائج <?php echo $start; ?> - <?php echo $end; ?> من إجمالى <?php echo $totalPages; ?></span>
        </div> 

        <div class="hidden totalPages"><?php if(isset($totalPages)) {echo $totalPages;} ?></div>
        <div class="hidden currentPage"><?php if(isset($page)) {echo $page;} ?></div>
        <?php } ?>
    </div>
<div class="clear"></div>
</div>
            
